#ifndef FILE_H
#define FILE_H

#include <fstream>
#include <string>
#include <dirent.h>

#include "bga/system/ConfigDLL.h"

/*!
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

class BOARD_HELL_ENGINE File
{
    public:
        File(const std::string& filename = "");
        File(const File& copy);
        virtual ~File();

        File& operator=(const File& file);

        static bool exists(const std::string& filename, const std::string& directory = ".");
        bool exists() const;
        void open();
        void close();

        /**
         * \brief get the full name of the filename
         * \return the fullname of the filename
         */
        const std::string& getFullName() const;

        template< typename T >
        bool operator>>(T& data);

    private:
        std::ifstream stream;
        std::string fullName;

        static bool readDir(DIR* dir, const std::string& filename);

};

template< typename T >
bool File::operator>>(T& data)
{
    return (this->stream >> data);
}

}

#endif // FILE_H
